#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N = 1e6 + 10;
ll n, m;
ll a[N];

ll calc(int x){
	ll ret = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] > x){
			ret += a[i] - x;
		}
	}
	return ret;
}

int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1 , a + 1 + n);
	ll l = 1, r = 4e5;
	while(l < r){
		ll mid = (l + r + 1) / 2;
		if(calc(mid) >= m) l = mid;
		else r = mid - 1;
	}
	cout << l << endl;
	return 0;
}
